<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>智联同城——小程序管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <style type="text/css">
  .tongji-box{
    text-align: center;
    background: #63BA79;
    padding:20px;
    color: #fff;
  }
  .tongji-title{
    font-size: 26px;
  }
  .tongji-num{
    font-size: 24px;
  }
  #chart-box{
    margin-top: 30px;
    height: 500px;
  }
  </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">智联同城</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item "><a href="{:U('Index/index')}">首页</a></li>
      <li class="layui-nav-item"><a href="{:U('InfoCate/index')}">分类信息管理</a></li>
      <li class="layui-nav-item"><a href="{:U('ShopCate/index')}">好店管理</a></li>
      <li class="layui-nav-item"><a href="{:U('Quan/index')}">同城圈管理</a></li>
      <li class="layui-nav-item"><a href="{:U('Member/index')}">用户管理</a></li>
      <li class="layui-nav-item"><a href="{:U('Takeout/index')}">餐饮管理</a></li>
      <li class="layui-nav-item layui-this" ><a href="{:U('Credit/flash')}">积分商城</a></li>
      <li class="layui-nav-item"><a href="{:U('Home/Index/index')}">切换小程序</a></li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="{$Think.session.wechat.headimg}" class="layui-nav-img">
          {$Think.session.wechat.nickname}
        </a>
        <dl class="layui-nav-child">
          <dd><a href="{:U('Home/Index/index')}">切换小程序</a></dd>
          <!-- <dd><a href="">安全设置</a></dd> -->
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="{$Think.session.headimgurl}" class="layui-nav-img">
          {$Think.session.nickname}
        </a>
        <dl class="layui-nav-child">
          <dd><a href="{:U('Home/Public/logout')}">退出登录</a></dd>
          <!-- <dd><a href="">安全设置</a></dd> -->
        </dl>
      </li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">

        <li class="layui-nav-item">
          <a class="" href="javascript:;">设置</a>
          <dl class="layui-nav-child">
            <dd class=""><a href="{:U('index/nav')}">&nbsp;&nbsp;&nbsp;&nbsp;基本设置</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">积分签到</a>
          <dl class="layui-nav-child">
            <dd class="layui-this"><a href="{:U('Credit/sign_set')}">&nbsp;&nbsp;&nbsp;&nbsp;签到设置</a></dd>
          </dl>
        </li>
      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding:0 15px;">
      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>签到规则</legend>
      </fieldset>

      <div class="layui-collapse " lay-filter="test">
        <div class="layui-colla-item ">
          <h2 class="layui-colla-title">签到规则说明</h2>
          <div class="layui-colla-content layui-show">
           <!-- <p>签到周期：签到周期是计算连续签到天数、总签到天数的依据，自然月则读取本月的连续签到天数、总签到天数，不限制签则计算所有签到天数</p>
            <p>补签设置：可以设置开启补签功能，可设置补签费用(积分或者余额)，费用可为空</p>
            <p>普通奖励：可以使用自定义替换页面中出现的文字</p>-->
            <p>普通奖励：普通奖励分为首次签到奖励、日常签到奖励</p>
            <p>连签奖励：可设置连续签到指定天数领取指定奖励，不设置则不显示</p>
            <!--<p>总签奖励：可设置总签到到达指定天数领取指定奖励，不设置则不显示</p>
            <p>特殊奖励：可根据日期设置特殊日期，并可以设置奖励，例如“周年庆”奖励100积分(可只设置标题不设置奖励)</p>-->
          </div>
        </div>
      </div>

      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>签到设置(不赠送积分请输入0)</legend>
      </fieldset>
      <form class="layui-form layui-form-pane" action="">

        <div class="layui-collapse " lay-filter="test">
          <div class="layui-colla-item ">
            <h2 class="layui-colla-title">普通奖励(自动发放)</h2>
            <div class="layui-colla-content layui-show">

              <div class="layui-form-item" >
                <label class="layui-form-label" >首次奖励</label>
                <div class="layui-input-inline">
                  <input type="number" name="first"  value="{$info.first}"  placeholder="0为不赠送" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">积分</div>
              </div>
              <div class="layui-form-item" >
                <label class="layui-form-label" >日常奖励</label>
                <div class="layui-input-inline">
                  <input type="number" name="normal"  value="{$info.normal}"  placeholder="0为不赠送" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">积分</div>
              </div>

            </div>
          </div>
        </div>

        <div class="layui-collapse " lay-filter="test">
          <div class="layui-colla-item ">
            <h2 class="layui-colla-title">连续奖励(手动领取)</h2>
            <div class="layui-colla-content layui-show" id="box">

              <foreach name="info.arr" item="v">
              <div class="layui-form-item" >
                <label class="layui-form-label" >连续签到</label>
                <div class="layui-input-inline">
                  <input type="number" name="sign_con_day" value="{$v.sign_con_day}"  placeholder="" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">天</div>
                <label class="layui-form-label" >领取</label>
                <div class="layui-input-inline">
                  <input type="number" name="sign_con_credit" value="{$v.sign_con_credit}"  placeholder="" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">积分</div>

                <div class="layui-btn-group" style="float: right;margin-right: 50%">
                  <span class="layui-btn layui-btn-primary layui-btn-sm add">
                    <i class="layui-icon">&#xe654;</i>
                  </span>
                  <span class="layui-btn layui-btn-primary layui-btn-sm del">
                    <i class="layui-icon">&#xe640;</i>
                  </span>
                </div>
              </div>
              </foreach>

            </div>
          </div>
        </div>

        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit="*" lay-filter="*">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
      </form>

    </div>
  </div>

  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © 2017-2018 <a href="https://www.58zltc.com" target="_blank">智联同城</a> All Rights Reserved.
  </div>
</div>

<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/js/jquery-1.11.1.min.js" charset="utf-8"></script>
<script>
//JavaScript代码区域
layui.use(['form','upload','element','laypage','layer'], function(){
  var element = layui.element;
  var form = layui.form
          ,$ = layui.jquery

//监听提交
  form.on('submit(*)', function(data){
    console.log(data);
    var sign_con_day = [];
    var sign_con_credit = [];
    $.each(data.form,function(k,v){
      //签到天数数组
      if(v.name == 'sign_con_day')
      {
        sign_con_day.push(v.value);
      }
      //签到天数赠送积分数组
      if(v.name == 'sign_con_credit')
      {
        sign_con_credit.push(v.value);
      }
    })


    var post_data = data.field;
    post_data.sign_con_credit = sign_con_credit;
    post_data.sign_con_day = sign_con_day;


    $.post("{:U('sign_set')}", post_data, function(e) {
      layer.alert(e.info,function(index){
        if(e.status == 1){
          location.reload();
        }else{
          layer.close(index);
        }
      });
    });
    return false;
  });
});


/*$.post("{:U('pian')}", {status: status}, function(e) {
  if(e.status == 1){
    layer.msg(e.info,{icon: 6,time:1000});
    setTimeout("location.reload()",1000);
  }else{
    layer.msg(e.info,{icon:1,time:1000});
  }
});*/

</script>
<script>
  //添加一个奖励设置
  $(document).on('click','.add',function(){
    var html =  '<div class="layui-form-item" >'+
            '<label class="layui-form-label" >连续签到</label>'+
            '<div class="layui-input-inline">'+
            '<input type="number" name="sign_con_day"  placeholder="" autocomplete="off" class="layui-input">'+
            '</div>'+
            '<div class="layui-form-mid layui-word-aux">天</div>'+
            '<label class="layui-form-label" >领取</label>'+
            '<div class="layui-input-inline">'+
            '<input type="number" name="sign_con_credit"  placeholder="" autocomplete="off" class="layui-input">'+
            '</div>'+
            '<div class="layui-form-mid layui-word-aux">积分</div>'+

            '<div class="layui-btn-group" style="float: right;margin-right: 50%">'+
            '<span class="layui-btn layui-btn-primary layui-btn-sm add">'+
            '<i class="layui-icon">&#xe654;</i>'+
            '</span>'+
            '<span class="layui-btn layui-btn-primary layui-btn-sm del">'+
            '<i class="layui-icon">&#xe640;</i>'+
            '</span>'+
            '</div>'+
            '</div>';
    $('#box').append(html);
  })

  //删除对应的html
  $(document).on('click','.del',function(){
    $(this).parents('.layui-form-item').html('');
  })
</script>
</body>
</html>
